const merge = require('webpack-merge');
const common = require('./webpack.prod.common.js');
const path = require('path');
const webpack = require('webpack');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const connectJs = require('./mergeConfig.json');

module.exports = merge(common, {
  entry: {
    AngularJs: connectJs.mergeJs,
    main: './frameworkCode/jsDependencies.js'
  },
  output: {
    path: path.resolve(__dirname, 'dist/source'),
    filename: 'js/[name].js'
  },
  module: {
    rules: [
      {
        test: /\.scss$/,
        use: ExtractTextPlugin.extract({
          fallback: 'style-loader',
          use: [
            {
              loader: 'css-loader?sourceMap',
              options: {
                minimize: false,
                sourceMap: true
              }
            },
            {
              loader: 'sass-loader?sourceMap',
              options: {
                minimize: false,
                sourceMap: true
              }
            }
          ]
        })
      }
    ]
  },
  plugins: [
    new CleanWebpackPlugin(['dist/source']),
    new ExtractTextPlugin({
      filename: 'css/index.css'
    })
  ],
  devtool: 'source-map'
});
